<template>
  <div class="contentmain">
    <PullRefresh @refresh="updateItems">
      <div slot="pullRefreshSlot">
        <ItemList :items="items">
          <FollowButton :item="items[0]" slot="itemListButton"></FollowButton>
        </ItemList>
      </div>
    </PullRefresh>
    <!-- <van-pull-refresh
      v-model="isLoading"
      @refresh="onRefresh"
      :pulling-text="this.$t('lang.下拉即可刷新')"
      :loosing-text="this.$t('lang.释放即可刷新')"
      :loading-text="this.$t('lang.加载中')"
    >
      <ItemList :items="items">
        <FollowButton :item="items[0]" slot="itemListButton"></FollowButton>
      </ItemList>
    </van-pull-refresh> -->
  </div>
</template>
<script>
export default {
  name: "ContentMain",
  data() {
    return {
      items: [],
      isLoading: false,
    };
  },
  components: {
    PullRefresh: () =>
      import(
        /* webpackChunkName:"pullRefresh" */ "../../components/common/pullRefresh.vue"
      ),
    ItemList: () =>
      import(
        /* webpackChunkName: "homeMain" */ "../../components/common/itemList"
      ),
    FollowButton: () =>
      import(
        /* webpackChunkName:"followButton" */ "../../components/common/followButton.vue"
      ),
  },
  created() {
    this.updateItems(1).then(() => {});
  },
  mounted() {
    window.scrollTo(1, 1);
  },
  methods: {
    onRefresh() {
      this.isLoading = false;
    },
    updateItems(pageNum, callback) {
      let that = this;
      return new Promise((resolve, reject) => {
        that.items = [
          {
            id: "0123456",
            userId: "0123456",
            userHead:
              "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595233833221&di=8cf8621bb5bdae4844362dfe99c54191&imgtype=0&src=http%3A%2F%2Fb.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fbd315c6034a85edf8c1758e240540923dc547553.jpg",
            nickName: "undefined",
            position: "中国",
            isNewContent: true,
            contentId: "0123456",
            content: [
              {
                type: "image",
                url:
                  "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=18296136,276139235&fm=26&gp=0.jpg",
              },
            ],
            tags: [
              "早晨",
              "asdfasdf",
              "电影",
              "娱乐自己",
              "标签测试",
              "线上测试",
            ],
            isGood: true,
            goodCount: 2314,
            isCollection: true,
            comments: {
              list: [
                {
                  userid: "0123456",
                  nickName: "test",
                  content: "comment content.",
                },
                {
                  userid: "0123456",
                  nickName: "adfasdfasd",
                  content: "comment content. adfasdfasdfas",
                },
              ],
              count: 3312,
            },
            lastTime: 1595245074825,
          },
        ];
        callback && callback();
        resolve();
      });
    },
  },
};
</script>
<style lang="less">
@base: 23.44rem;
.contentmain {
}
</style>
